package com.sora.pipeline.domain.dto;

import com.sora.pipeline.domain.Defect;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 缺陷详细信息DTO
 * 包含缺陷类型名和等级名
 * 
 * @author system
 * @since 2025-01-20
 */
@Data
public class DefectWithDetailsDTO {
    
    /**
     * 缺陷ID
     */
    private Long id;
    
    /**
     * 缺陷代码
     */
    private String code;
    
    /**
     * 线路ID
     */
    private Long lineId;
    
    /**
     * 线路代码
     */
    private String lineCode;
    
    /**
     * 线路名称
     */
    private String lineName;
    
    /**
     * 里程碑
     */
    private String milestone;
    
    /**
     * 里程碑ID
     */
    private Long milestoneId;
    
    /**
     * 类型ID
     */
    private Integer typeId;
    
    /**
     * 类型名称
     */
    private String typeName;
    
    /**
     * 等级ID
     */
    private Integer levelId;
    
    /**
     * 等级名称
     */
    private String levelName;
    
    /**
     * 状态
     */
    private String status;
    
    /**
     * 位置
     */
    private String location;
    
    /**
     * 描述
     */
    private String description;
    
    /**
     * 上报人ID
     */
    private Long reporterId;
    
    /**
     * 上报人姓名
     */
    private String reporterName;
    
    /**
     * 上报人用户名
     */
    private String reporterUsername;
    
    /**
     * 上报时间
     */
    private LocalDateTime reportTime;
    
    /**
     * 图片JSON
     */
    private String imagesJson;
    
    /**
     * 备注
     */
    private String remarks;
    
    /**
     * 创建时间
     */
    private LocalDateTime createdAt;
    
    /**
     * 创建人ID
     */
    private Long createdBy;
    
    /**
     * 更新时间
     */
    private LocalDateTime updatedAt;
    
    /**
     * 更新人ID
     */
    private Long updatedBy;
    
    /**
     * 是否删除
     */
    private Boolean deleted;
    
    /**
     * 从Defect实体转换
     */
    public static DefectWithDetailsDTO fromDefect(Defect defect) {
        DefectWithDetailsDTO dto = new DefectWithDetailsDTO();
        dto.setId(defect.getId());
        dto.setCode(defect.getCode());
        dto.setLineId(defect.getLineId());
        dto.setMilestone(defect.getMilestone());
        dto.setMilestoneId(defect.getMilestoneId());
        dto.setTypeId(defect.getTypeId());
        dto.setLevelId(defect.getLevelId());
        dto.setStatus(defect.getStatus());
        dto.setLocation(defect.getLocation());
        dto.setDescription(defect.getDescription());
        dto.setReporterId(defect.getReporterId());
        dto.setReportTime(defect.getReportTime());
        dto.setImagesJson(defect.getImagesJson());
        dto.setRemarks(defect.getRemarks());
        dto.setCreatedAt(defect.getCreatedAt());
        dto.setCreatedBy(defect.getCreatedBy());
        dto.setUpdatedAt(defect.getUpdatedAt());
        dto.setUpdatedBy(defect.getUpdatedBy());
        dto.setDeleted(defect.getDeleted());
        return dto;
    }
}
